{extend name="base" /} {block name="body"}
<div class="right">
	<div class="rigtop">
		<span class="title">商品分类</span>

	</div>
	<div class="indrig_con orders_con">
		<div class="zizh_btnbox online_btnbox"> 
			<button class="zizh_btn" type="button" onclick="types_add('{:url('shop/types_add')}')">创建分类</button>
		</div>
		<div class="help_lisbox" style="margin-top: 0px;">
			<table class="zizh_table1">
				<thead>
					<tr>
						<th>分类名</th>
						<th>排序</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="tbody">
					{volist name="types_list" id="vo" empty="$empty"}
					<tr>
						<td>{$vo.name|default='0'}</td>
						<td>{$vo.sort|default='0'}</td>
						<td>
							<a href="#"  onclick="types_edit('{:url('shop/types_edit',['id'=>$vo.id])}')">编辑</a>
							<a href="#"  onclick="types_del({$vo.id})">删除</a>
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			<div class="fenye" style="display: block;">
				<ul class="pagination">
					{$types_list->render()}
				</ul>
			</div>
		</div>
	</div>
</div>

{/block}
{block name="script"}
<script>
	function types_add(url) {
		layer.open({
		  type: 2,
		  title: '创建分类',
		  shadeClose: true,
		  shade: 0.8,
		  area: ['500px', '240px'],
		  content: url
		}); 
	}
	function types_edit(url) {
		layer.open({
		  type: 2,
		  title: '修改分类',
		  shadeClose: true,
		  shade: 0.8,
		  area: ['500px', '240px'],
		  content: url
		}); 
	}
	
	//删除
	function types_del(id){
		layer.confirm('您确定要修改吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				url: "{:url('shop/types_del')}",
				data: {
					id:id
				},
				success: function(data) {
					if(data.code==200){
	                	layer.msg(data.msg, {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							location.reload();
						});
	                }else{
	                	layer.msg(data.msg);
	                }
				}
			})
		})
	}
	
</script>
{/block}